<?php
class Jpenjualan_model extends CI_Model{
	function   __construct() {
        parent::__construct();
    }

    //page
	private $tbl = 'jenis_penjualan';

	function selectAll()
	{
		return $this->db->get($this->tbl)->result();
	}

	function get_list_data($limit = 10, $offset = 0)
  	{
		$this->db->limit($limit, $offset);
  		$this->db->order_by('intid_jpenjualan','asc');
		return $this->db->get($this->tbl,$limit,$offset);
  	}

	function countData()
	{
	  	return $this->db->count_all($this->tbl);
  	}
//end page
    function getJpenjualan(){

	   $query = $this->db->query("SELECT *  FROM jenis_penjualan
               ORDER BY intid_jpenjualan ASC");
	   return $query->result();
    }

    function insert($data){
	$data = array(
           
            'strnama_jpenjualan' => $this->input->post('strnama_jpenjualan')
                );
        $this->db->insert('jenis_penjualan', $data);
	}

   function delete($idjpenjualan){
       $this->db->where('intid_jpenjualan', $idjpenjualan);
       $this->db->delete('jenis_penjualan');
    }

    function select($idjpenjualan){
       $query = $this->db->query("select * from jenis_penjualan where intid_jpenjualan = $idjpenjualan");
	   return $query->result();
    }

	function update($idjpenjualan){
            $data = array(
           
            'strnama_jpenjualan' => $this->input->post('strnama_jpenjualan')
                    );
            $this->db->where('intid_jpenjualan', $idjpenjualan);
            $this->db->update('jenis_penjualan',$data);
    }
     //test paging
  function getAllGrid($start,$limit,$sidx,$sord,$where){
//    $this->db->select('intid_unit,strnama_unit'); -->cara 1
//    $this->db->limit($limit);
//    if($where != NULL)$this->db->where($where,NULL,FALSE);
//    $this->db->order_by($sidx,$sord);
//    $query = $this->db->get('unit',$limit,$start);
//
//    return $query->result();
      //cara 2
      $query = $this->db->query("SELECT *
              FROM jenis_penjualan
              ORDER BY $sidx $sord LIMIT $start , $limit");
      return $query->result();
  }

  function get($intid_jpenjualan){
    $query = $this->db->getwhere('jenis_penjualan',array('intid_jpenjualan'=>$intid_jpenjualan));
    return $query->row_array();
  }
//end of test paging
}
?>
